package leecode

type ListNode203 struct {
	Val  int
	Next *ListNode203
}

func removeElements(head *ListNode203, val int) *ListNode203 {
	listHead := &ListNode203{}
	listHead.Next = head //创建虚拟头节点
	temp := listHead
	for temp != nil && temp.Next != nil {
		if temp.Next.Val != val {
			temp = temp.Next
		} else {
			temp.Next = temp.Next.Next
		}
	}
	return listHead.Next
}
